1 <?php
2     include(
"../includes/config.php");
3     session_start();
4     
if(isset($_SESSION['manufacturer_login'])) {
5         
if($_SESSION['manufacturer_login'] == true) {
6             $querySelectProduct =
"SELECT * FROM products,unit WHERE products.unit=unit.id AND quantity IS NOT NULL";
7             $resultSelectProduct = mysqli_query($con,$querySelectProduct);
8             
if($_SERVER['REQUEST_METHOD'] == "POST") {
9                 
if(isset($_POST['txtQuantity'])){
10                     $arrayQuantity = $_POST[
'txtQuantity'];
11                     
foreach($arrayQuantity as $key => $value) {
12                         $queryUpdateStock =
"UPDATE products SET quantity='$value' WHERE pro_id='$key'";
13                         $result = mysqli_query($con,$queryUpdateStock);
14                     }
15                     
if(!$result) {
16                         $requireErr =
"Updating Product Failed";
17                     }
18                     
else {
19                         echo
"<script> alert(\"Stock Updated Successfully\"); </script>";
20                         header(
'Refresh:0');
21                     }
22                 }
23                 
24             }
25         }
26         
else {
27             header(
'Location:../index.php');
28         }
29     }
30     
else {
31         header(
'Location:../index.php');
32     }
33 ?>
34 <!DOCTYPE html>
35 <html>
36 <head>
37     <title> Admin: Home</title>
38     <link rel=
"stylesheet" href="../includes/main_style.css" >
39 </head>
40 <body>
41     <?php
42         include(
"../includes/header.inc.php");
43         include(
"../includes/nav_manufacturer.inc.php");
44         include(
"../includes/aside_manufacturer.inc.php");
45     ?>
46     <section>
47         <h1>Manage Stock</h1>
48         <form action=
"" method="POST" class="form">
49         <table
class="table_displayData" style="margin-top:20px;">
50             <tr>
51                 <th> Product ID </th>
52                 <th> Name </th>
53                 <th> Unit </th>
54                 <th> Quantity </th>
55             </tr>
56             <?php
while($rowSelectProduct = mysqli_fetch_array($resultSelectProduct)){ ?>
57             <tr>
58                 <td><?php echo $rowSelectProduct[
'pro_id']; ?></td>
59                 <td><?php echo $rowSelectProduct[
'pro_name']; ?></td>
60                 <td><?php echo $rowSelectProduct[
'unit_name']; ?></td>
61                 <td><input type=
"text" name="txtQuantity[<?php echo $rowSelectProduct['pro_id']; ?>]" value="<?php echo $rowSelectProduct['quantity']; ?>" size="10"/></td>
62             </tr>
63             <?php } ?>
64         </table>
65             <input id=
"btnSubmit" type="submit" value="Update Stock" class="submit_button" />
66         </form>
67     </section>
68     <?php
69         include(
"../includes/footer.inc.php");
70     ?>
71 </body>
72 </html>


Gõ tìm kiếm nhanh...